#version 460
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
#extension GL_GOOGLE_include_directive : enable

struct SModelBuffer
{
    mat4 Model;
    uint ObjectID; // 32位无符号整数
};

#include "../CppMacros.h"

layout (set=0, binding = 0) uniform ModelBufferBatch
{
    SModelBuffer Models[MESH_BATCH_SIZE];
} ModelBuffer;

layout (set=1, binding = 0) uniform SceneBufferObject
{
    mat4 ProjectionView;

} SceneBuffer;

//顶点属性
layout (location = 0) in vec3 pos;
layout (location = 1) in vec2 inTexCoords;
layout (location = 2) in vec3 inVertexNormal;

layout (location = 0) flat out uint outObjectID;

void main() 
{
    vec4 WorldPos=ModelBuffer.Models[gl_InstanceIndex].Model*vec4(pos,1);
    gl_Position = 
        SceneBuffer.ProjectionView  // project * view matrix
        * WorldPos;
  
    outObjectID=ModelBuffer.Models[gl_InstanceIndex].ObjectID;
}